package com.ys.web.sys.notice.vo;

/**
 * @author quxinjun
 * @version 1.0.0
 * @ClassName SystemNoticeVo.java
 * @Description TODO
 * @createTime 2021年11月01日 15:43:00
 */

import cn.hutool.core.util.IdUtil;
import com.ys.base.BaseConstants;
import com.ys.utils.base.j2se.DateUtil;
import com.ys.utils.base.j2se.StringHandler;
import com.ys.utils.spring.config.SystemError;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@Accessors(chain = true)
public class SystemNoticeVo {

    public String id;
    public String title;
    public String content;
    public Long userId;
    public String createTime;
    public Boolean isAll = false;

    public void checkParam() {
        if (StringHandler.isEmpty(this.title)) {
            SystemError.wrapBs("500", "通知标题不能为空");
        }

        if (StringHandler.isEmpty(this.content)) {
            SystemError.wrapBs("500", "通知内容不能为空");
        }

        this.setId(IdUtil.randomUUID().replaceAll("-", ""));
        this.setCreateTime(DateUtil.getDate(new Date(), BaseConstants.BASE_FORMAT));
    }

    public static SystemNoticeVo build(String title,String content,long userId){
        SystemNoticeVo vo  = new SystemNoticeVo();
        vo.setTitle(title);
        vo.setContent(content);
        vo.setUserId(userId);
        return vo;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Boolean getIsAll() {
        return isAll;
    }

    public void setIsAll(Boolean all) {
        isAll = all;
    }
}
